/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package interfaces;

import acceso_datos.EntidadEmergenciaDB;
import datos.AlarmaProducto;
import datos.WBombero;
import datos.Coordinador;
import datos.WEmergencia;
import datos.Emergencie;
import datos.Factory;
import datos.FactoryMethod;
import datos.Notificador;
import datos.Operador;
import datos.Policia;
import datos.RegistroIncidente;
import datos.RegistroLlamada;
import datos.TipoEmergencia;
import datos.TipoIncidente;
import exceptions.*;
import java.sql.Date;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
import org.postgresql.util.PSQLException;

/**
 *
 * @author miguesaca
 */
public class Panel_SOS extends Panel_T {

    private String cedula, nombre, apellido, telefono, direccion, zona, tipo, observacion, descripcionGeneral;
    private Date fecha;
    private Notificador notificador;
    private Operador operador;
    private Coordinador coordinador;
    private Ventana ventana;
    private Emergencie emergencie;
    private RegistroLlamada registroLlamada;
    private RegistroIncidente registroIncidente;

    public Panel_SOS(Ventana ventana) {
        this.ventana = ventana;
        initComponents();
    }

    public void getTabla_Notificador(javax.swing.table.DefaultTableModel tablaModelo) {
        Tabla_Notificador.setModel(tablaModelo);
        // Instanciamos el TableRowSorter y lo añadimos al JTable Para ordenarlo
        TableRowSorter<TableModel> elQueOrdena = new TableRowSorter<TableModel>(tablaModelo);
        Tabla_Notificador.setRowSorter(elQueOrdena);
    }

    // Solo se ejecuta cuando se inserta un notificador
    private void getTabla_NotificadorSOS() {
        Object nameColumns[] = {"cedula", "nombre", "apellido", "telefono"};
        DefaultTableModel miTableModel = new DefaultTableModel(nameColumns, 0);
        Object nuevaFila[] = {cedula, nombre, apellido, telefono};
        miTableModel.addRow(nuevaFila);
        Tabla_NotificardorSOS.setModel(miTableModel);
    }

    private void getTabla_RegistroLlamada(javax.swing.table.DefaultTableModel tablaModelo) {
        Tabla_RegistroLlamada.setModel(tablaModelo);
        // Instanciamos el TableRowSorter y lo añadimos al JTable Para ordenarlo
        TableRowSorter<TableModel> elQueOrdena = new TableRowSorter<TableModel>(tablaModelo);
        Tabla_RegistroLlamada.setRowSorter(elQueOrdena);
    }

    private void getTabla_OperadorAtendio() {
        Object nameColumns[] = {"cedula", "nombre", "apellido", "telefono"};
        DefaultTableModel miTableModel = new DefaultTableModel(nameColumns, 0);
        Object nuevaFila[] = {operador.getCedula(), operador.getNombre(), operador.getApellido(), operador.getTelefono()};
        miTableModel.addRow(nuevaFila);
        Tabla_OperadorAtendio.setModel(miTableModel);
    }

    private void getTabla_RegistroIncidente(javax.swing.table.DefaultTableModel tablaModelo) {
        tabla_RegistroIncidente.setModel(tablaModelo);
        // Instanciamos el TableRowSorter y lo añadimos al JTable Para ordenarlo
        TableRowSorter<TableModel> elQueOrdena = new TableRowSorter<TableModel>(tablaModelo);
        tabla_RegistroIncidente.setRowSorter(elQueOrdena);
    }

    private void guardarNotificador() {
        try {
            cedula = text_Cedula.getText();
            nombre = text_Nombre.getText();
            apellido = text_Apellido.getText();
            telefono = text_Telefono.getText();
            direccion = text_Direccion.getText();
            notificador = new Notificador(cedula, nombre, apellido, telefono, direccion);
            ventana.getGestorNotificadores().insertar(notificador);

            guardarRegistroLlamada();
            guardarEmergencia();
            getTabla_NotificadorSOS();

        } catch (NotificadorException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        } catch (AlfanumericoException ex) {
            JOptionPane.showMessageDialog(null, "Notificador: " + ex.getMessage());
        } catch (SQLException ex) {
            Logger.getLogger(Panel_SOS.class.getName()).log(Level.SEVERE, null, ex);
        }

        ventana.actualizar("----");
    }

    private void guardarRegistroLlamada() {
        try {
            /// obtener la fecha actual del sistema
            java.util.Date fechaD;
            fechaD = new java.util.Date();
            fecha = new java.sql.Date(fechaD.getTime());
            java.sql.Time horams = new java.sql.Time(fechaD.getTime());

            operador = ventana.getGestorOperadoras().buscar(ventana.getPanel_Login().getCedula());
            registroLlamada = new RegistroLlamada(0, fecha, horams, text_Lugar1.getText(), text_Lugar2.getText(), notificador, operador);
            ventana.getGestorRegistroLlamadas().insertar(registroLlamada);

            text_Lugar1.setText("");
            text_Lugar2.setText("");
        } catch (UsuarioException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        } catch (RegistroLlamadaException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        } catch (AlfanumericoException ex) {
            JOptionPane.showMessageDialog(null, "Direccion: " + ex.getMessage());
        } catch (SQLException ex) {
            Logger.getLogger(Panel_SOS.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    int te = 0, ei = 0;

    private void guardarEmergencia() {

        try {
            zona = text_Zona.getText();
            descripcionGeneral = text_Descripcion.getText();

            TipoEmergencia tipoEmergencia = new TipoEmergencia(0, "");
            emergencie = new Emergencie(ei++, zona, descripcionGeneral, registroLlamada, tipoEmergencia);
            FactoryMethod factory = new Factory();
            AlarmaProducto alarma;
            
            if (cmb_tipo_Emergencia.getSelectedIndex() == 0) {
                tipoEmergencia = new TipoEmergencia(1, "incendio");
                emergencie.setTipoEmergencia(tipoEmergencia);
                alarma = factory.crearAlarma("Incendio", emergencie);
            }
            if (cmb_tipo_Emergencia.getSelectedIndex() == 1) {
                tipoEmergencia = new TipoEmergencia(2, "robo");
                emergencie.setTipoEmergencia(tipoEmergencia);
                alarma = factory.crearAlarma("Robo", emergencie);
            }
            

            ventana.getGestorEmergencia().insertar(emergencie);

//            WEmergencia emergencia=this.emergencie;
//            
//            ArrayList entidades=new ArrayList();
//            for (int i = 0; i < Tabla_Unidades.getRowCount(); i++) {
//                String entidadC=(String)Tabla_Unidades.getValueAt(i, 0);
//                if(entidadC.equals("Policia")){
//                    emergencia=new Policia(emergencia);
//                }else if(entidadC.equals("Bomberos")){
//                    emergencia=new WBomberoo(emergencia);
//                }
//            }
//            
//            emergencia.notificarEntidad(this.emergencie.getId());


            text_Zona.setText("");
        } catch (EmergenciaInicialException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        } catch (AlfanumericoException ex) {
            JOptionPane.showMessageDialog(null, "Emergencia: " + ex.getMessage());
        } catch (SQLException ex) {
            Logger.getLogger(Panel_SOS.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void cargarNotificador() {
        cedula = notificador.getCedula();
        text_Cedula.setText(cedula);
        nombre = notificador.getNombre();
        text_Nombre.setText(nombre);
        apellido = notificador.getApellido();
        text_Apellido.setText(apellido);
        telefono = notificador.getTelefono();
        text_Telefono.setText(telefono);
        direccion = notificador.getDireccion();
        text_Direccion.setText(direccion);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        panel_Llamadas = new Panel_T();
        jPanel1 = new Panel_T();
        jLabel1 = new javax.swing.JLabel();
        tipo_Emergencia = new javax.swing.JComboBox();
        jScrollPane7 = new javax.swing.JScrollPane();
        Tabla_Unidades = new javax.swing.JTable();
        jPanel2 = new Panel_T();
        label_Cedula = new javax.swing.JLabel();
        boton_Buscar = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        Tabla_NotificardorSOS = new javax.swing.JTable();
        text_BuscarCedula = new javax.swing.JTextField();
        jPanel3 = new Panel_T();
        jLabel2 = new javax.swing.JLabel();
        text_Lugar1 = new javax.swing.JTextField();
        text_Lugar2 = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        text_Zona = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        text_Descripcion = new javax.swing.JTextField();
        jLabel33 = new javax.swing.JLabel();
        cmb_tipo_Emergencia = new javax.swing.JComboBox();
        jPanel5 = new Panel_T();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        text_Nombre = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        text_Apellido = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        text_Telefono = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        text_Direccion = new javax.swing.JTextField();
        text_Cedula = new javax.swing.JTextField();
        jPanel4 = new Panel_T();
        boton_Guardar = new javax.swing.JButton();
        jPanel6 = new Panel_T();
        jPanel7 = new Panel_T();
        jLabel13 = new javax.swing.JLabel();
        jScrollPane5 = new javax.swing.JScrollPane();
        Tabla_Notificador = new javax.swing.JTable();
        jScrollPane6 = new javax.swing.JScrollPane();
        Tabla_OperadorAtendio = new javax.swing.JTable();
        jLabel24 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jPanel8 = new Panel_T();
        jScrollPane8 = new javax.swing.JScrollPane();
        Tabla_RegistroLlamada = new javax.swing.JTable();
        jLabel26 = new javax.swing.JLabel();
        jPanel9 = new Panel_T();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        label_Lugar = new javax.swing.JLabel();
        label_Zona = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tabla_Entidades = new javax.swing.JTable();
        jLabel14 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        textArea_DescEmergencia = new javax.swing.JTextArea();
        jPanel10 = new Panel_T();
        jPanel11 = new javax.swing.JPanel();
        text_Tipo = new javax.swing.JTextField();
        jLabel21 = new javax.swing.JLabel();
        text_Observacion = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();
        label_Cedula1 = new javax.swing.JLabel();
        text_BuscarEmergecia = new javax.swing.JTextField();
        boton_BuscarEmergencia = new javax.swing.JButton();
        boton_Guardar1 = new javax.swing.JButton();
        jPanel12 = new javax.swing.JPanel();
        jScrollPane9 = new javax.swing.JScrollPane();
        tabla_RegistroIncidente = new javax.swing.JTable();
        jLabel32 = new javax.swing.JLabel();
        jPanel13 = new javax.swing.JPanel();
        jLabel20 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        label_iReferencia = new javax.swing.JLabel();
        label_iZona = new javax.swing.JLabel();
        label_iOperador = new javax.swing.JLabel();
        label_iDescripcion = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        label_iNotificador = new javax.swing.JLabel();
        jLabel30 = new javax.swing.JLabel();
        jLabel31 = new javax.swing.JLabel();
        label_iTipo = new javax.swing.JLabel();
        label_iObservacion = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 153, 102));

        panel_Llamadas.setBackground(new java.awt.Color(255, 255, 255));

        jPanel1.setBackground(new java.awt.Color(102, 102, 102));

        jLabel1.setBackground(new java.awt.Color(102, 102, 102));
        jLabel1.setText("Entidades de Cooperacion");

        tipo_Emergencia.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                tipo_EmergenciaItemStateChanged(evt);
            }
        });

        Tabla_Unidades.setBackground(new java.awt.Color(204, 204, 204));
        Tabla_Unidades.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Unidades"
            }
        ));
        Tabla_Unidades.setOpaque(false);
        jScrollPane7.setViewportView(Tabla_Unidades);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(4, 4, 4)
                        .addComponent(jLabel1)
                        .addContainerGap(82, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
                            .addComponent(tipo_Emergencia, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(0, 81, Short.MAX_VALUE))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tipo_Emergencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel2.setBackground(new java.awt.Color(102, 102, 102));

        label_Cedula.setText("Cedula");

        boton_Buscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icon_buscar1.png"))); // NOI18N
        boton_Buscar.setBorderPainted(false);
        boton_Buscar.setContentAreaFilled(false);
        boton_Buscar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        boton_Buscar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        boton_Buscar.setIconTextGap(-3);
        boton_Buscar.setPreferredSize(new java.awt.Dimension(50, 50));
        boton_Buscar.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icon_buscar2.png"))); // NOI18N
        boton_Buscar.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icon_buscar0.png"))); // NOI18N
        boton_Buscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boton_BuscarActionPerformed(evt);
            }
        });

        jLabel3.setText("DATOS PERSONALES");

        Tabla_NotificardorSOS.setBackground(new java.awt.Color(204, 204, 204));
        Tabla_NotificardorSOS.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null}
            },
            new String [] {
                "Cedula", "Nombre", "Telefono", "Edad"
            }
        ));
        Tabla_NotificardorSOS.setOpaque(false);
        jScrollPane4.setViewportView(Tabla_NotificardorSOS);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 539, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(label_Cedula)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(text_BuscarCedula, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(boton_Buscar, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(143, 143, 143)
                                .addComponent(jLabel3)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addGap(25, 25, 25)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(boton_Buscar, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(text_BuscarCedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(label_Cedula)))
                .addGap(31, 31, 31)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setBackground(new java.awt.Color(102, 102, 102));

        jLabel2.setText("Lugar de Referencia");

        jLabel4.setText("Referencia1:");

        jLabel5.setText("Referencia2");

        jLabel6.setText("Zona del lugar:");

        jLabel7.setText("Descripcion de la Emergencia:");

        jLabel33.setText("Tipo Emergencia:");

        cmb_tipo_Emergencia.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Incendio", "Robo", "Accidente Transito" }));
        cmb_tipo_Emergencia.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cmb_tipo_EmergenciaItemStateChanged(evt);
            }
        });
        cmb_tipo_Emergencia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmb_tipo_EmergenciaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(114, 114, 114)
                .addComponent(jLabel2)
                .addContainerGap(150, Short.MAX_VALUE))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(text_Zona)
                    .addComponent(text_Descripcion, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel5)
                                    .addComponent(jLabel4))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(text_Lugar1)
                                    .addComponent(text_Lugar2)))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel6)
                                    .addComponent(jLabel7))
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel33, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cmb_tipo_Emergencia, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(19, 19, 19)))))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(15, 15, 15)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(text_Lugar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(text_Lugar2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel33)
                    .addComponent(cmb_tipo_Emergencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(text_Zona, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(text_Descripcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jPanel5.setBackground(new java.awt.Color(102, 102, 102));

        jLabel8.setText("I N S E R T A R");

        jLabel9.setText("Cedula:");

        jLabel10.setText("Nombre:");

        jLabel11.setText("Apellido");

        jLabel12.setText("Tlf:");

        jLabel25.setText("Direccion");

        text_Cedula.setEnabled(false);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                        .addGap(0, 148, Short.MAX_VALUE)
                        .addComponent(jLabel8)
                        .addGap(133, 133, 133))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel9)
                            .addComponent(jLabel10)
                            .addComponent(jLabel11)
                            .addComponent(jLabel25))
                        .addGap(21, 21, 21)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(text_Apellido)
                            .addComponent(text_Nombre)
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addComponent(text_Cedula)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel12)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(text_Telefono, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(text_Direccion, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addContainerGap())))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jLabel12)
                    .addComponent(text_Telefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(text_Cedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(text_Nombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(text_Apellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel25)
                    .addComponent(text_Direccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(18, Short.MAX_VALUE))
        );

        jPanel4.setBackground(new java.awt.Color(102, 102, 102));

        boton_Guardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icon_guardar1.png"))); // NOI18N
        boton_Guardar.setBorderPainted(false);
        boton_Guardar.setContentAreaFilled(false);
        boton_Guardar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        boton_Guardar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        boton_Guardar.setIconTextGap(-3);
        boton_Guardar.setPreferredSize(new java.awt.Dimension(50, 50));
        boton_Guardar.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icon_guardar2.png"))); // NOI18N
        boton_Guardar.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icon_guardar0.png"))); // NOI18N
        boton_Guardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boton_GuardarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addComponent(boton_Guardar, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(246, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
            .addComponent(boton_Guardar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        javax.swing.GroupLayout panel_LlamadasLayout = new javax.swing.GroupLayout(panel_Llamadas);
        panel_Llamadas.setLayout(panel_LlamadasLayout);
        panel_LlamadasLayout.setHorizontalGroup(
            panel_LlamadasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_LlamadasLayout.createSequentialGroup()
                .addGroup(panel_LlamadasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panel_LlamadasLayout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(panel_LlamadasLayout.createSequentialGroup()
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(panel_LlamadasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap())
        );
        panel_LlamadasLayout.setVerticalGroup(
            panel_LlamadasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_LlamadasLayout.createSequentialGroup()
                .addGroup(panel_LlamadasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(panel_LlamadasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(panel_LlamadasLayout.createSequentialGroup()
                        .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(42, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("LLamadas", panel_Llamadas);

        jPanel7.setBackground(new java.awt.Color(102, 102, 102));

        jLabel13.setText("E M E R G E N C I A");

        Tabla_Notificador.setBackground(new java.awt.Color(204, 204, 204));
        Tabla_Notificador.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Cedula", "Nombre", "Telefono", "Edad"
            }
        ));
        Tabla_Notificador.setOpaque(false);
        Tabla_Notificador.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                Tabla_NotificadorMousePressed(evt);
            }
        });
        jScrollPane5.setViewportView(Tabla_Notificador);

        Tabla_OperadorAtendio.setBackground(new java.awt.Color(204, 204, 204));
        Tabla_OperadorAtendio.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null}
            },
            new String [] {
                "Cedula", "Nombre", "Telefono", "Edad"
            }
        ));
        Tabla_OperadorAtendio.setOpaque(false);
        jScrollPane6.setViewportView(Tabla_OperadorAtendio);

        jLabel24.setText("Operadora quien atendio la llamada:");

        jLabel18.setText("Notificador:");

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(jLabel13)
                .addGap(169, 169, 169))
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 493, Short.MAX_VALUE)
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel24)
                            .addComponent(jLabel18))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addComponent(jLabel13)
                .addGap(15, 15, 15)
                .addComponent(jLabel18)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel24)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel8.setBackground(new java.awt.Color(102, 102, 102));

        Tabla_RegistroLlamada.setBackground(new java.awt.Color(204, 204, 204));
        Tabla_RegistroLlamada.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Cedula", "Nombre", "Telefono", "Edad"
            }
        ));
        Tabla_RegistroLlamada.setOpaque(false);
        Tabla_RegistroLlamada.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                Tabla_RegistroLlamadaMousePressed(evt);
            }
        });
        jScrollPane8.setViewportView(Tabla_RegistroLlamada);

        jLabel26.setBackground(new java.awt.Color(102, 102, 102));
        jLabel26.setText("Emergencia:");

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGap(106, 106, 106)
                        .addComponent(jLabel26))
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 407, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup()
                .addContainerGap(28, Short.MAX_VALUE)
                .addComponent(jLabel26)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(49, 49, 49))
        );

        jPanel9.setBackground(new java.awt.Color(102, 102, 102));

        jLabel15.setText("R  E S U M E N");

        jLabel16.setText("Referencia:");

        jLabel17.setText("Zona");

        jLabel19.setText("Descripcion de la Emergencia:");

        label_Lugar.setText("-------");

        label_Zona.setText("-------");

        tabla_Entidades.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null},
                {null},
                {null},
                {null}
            },
            new String [] {
                "Unidades"
            }
        ));
        jScrollPane3.setViewportView(tabla_Entidades);

        jLabel14.setBackground(new java.awt.Color(102, 102, 102));
        jLabel14.setText("Tipo de Emergencia");

        textArea_DescEmergencia.setColumns(20);
        textArea_DescEmergencia.setRows(5);
        jScrollPane1.setViewportView(textArea_DescEmergencia);

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel9Layout.createSequentialGroup()
                                .addComponent(jLabel17)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(label_Zona))
                            .addGroup(jPanel9Layout.createSequentialGroup()
                                .addComponent(jLabel16)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(label_Lugar))
                            .addComponent(jLabel19)))
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGap(114, 114, 114)
                        .addComponent(jLabel15))
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel14)))
                .addContainerGap(63, Short.MAX_VALUE))
            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING)
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGap(15, 15, 15)
                .addComponent(jLabel15)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(label_Lugar))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(label_Zona))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel19)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Detalles", jPanel6);

        jPanel11.setBackground(new java.awt.Color(153, 153, 255));

        jLabel21.setText("Tipo:");

        jLabel22.setText("Observacion:");

        label_Cedula1.setText("Numero de Emergencia");

        boton_BuscarEmergencia.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icon_buscar1.png"))); // NOI18N
        boton_BuscarEmergencia.setBorderPainted(false);
        boton_BuscarEmergencia.setContentAreaFilled(false);
        boton_BuscarEmergencia.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        boton_BuscarEmergencia.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        boton_BuscarEmergencia.setIconTextGap(-3);
        boton_BuscarEmergencia.setPreferredSize(new java.awt.Dimension(50, 50));
        boton_BuscarEmergencia.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icon_buscar2.png"))); // NOI18N
        boton_BuscarEmergencia.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icon_buscar0.png"))); // NOI18N
        boton_BuscarEmergencia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boton_BuscarEmergenciaActionPerformed(evt);
            }
        });

        boton_Guardar1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icon_guardar1.png"))); // NOI18N
        boton_Guardar1.setBorderPainted(false);
        boton_Guardar1.setContentAreaFilled(false);
        boton_Guardar1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        boton_Guardar1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        boton_Guardar1.setIconTextGap(-3);
        boton_Guardar1.setPreferredSize(new java.awt.Dimension(50, 50));
        boton_Guardar1.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icon_guardar2.png"))); // NOI18N
        boton_Guardar1.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icon_guardar0.png"))); // NOI18N
        boton_Guardar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boton_Guardar1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel11Layout.createSequentialGroup()
                        .addGap(38, 38, 38)
                        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel21)
                            .addComponent(jLabel22))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(text_Observacion)
                            .addGroup(jPanel11Layout.createSequentialGroup()
                                .addComponent(text_Tipo, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE))))
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(label_Cedula1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(text_BuscarEmergecia, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(boton_BuscarEmergencia, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(109, 109, 109))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel11Layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(boton_Guardar1, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(boton_BuscarEmergencia, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(text_BuscarEmergecia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(label_Cedula1)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(text_Tipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel21))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(text_Observacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel22))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE)
                .addComponent(boton_Guardar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jPanel12.setBackground(new java.awt.Color(153, 153, 255));

        tabla_RegistroIncidente.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Clave", "Coordinador", "Emergencia"
            }
        ));
        tabla_RegistroIncidente.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                tabla_RegistroIncidenteMousePressed(evt);
            }
        });
        jScrollPane9.setViewportView(tabla_RegistroIncidente);

        jLabel32.setText("Registro Incidente");

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addGap(140, 140, 140)
                .addComponent(jLabel32)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel32)
                .addGap(15, 15, 15)
                .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(98, Short.MAX_VALUE))
        );

        jPanel13.setBackground(new java.awt.Color(153, 153, 255));
        jPanel13.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jLabel20.setText("Referencia:");

        jLabel23.setText("Zona:");

        jLabel27.setText("Operador:");

        jLabel28.setText("Descripcion:");

        label_iReferencia.setText("---------------");

        label_iZona.setText("-------------------");

        label_iOperador.setText("---------------");

        label_iDescripcion.setText("-----");

        jLabel29.setText("Notificador:");

        label_iNotificador.setText("--------------");

        jLabel30.setText("Tipo:");

        jLabel31.setText("Observacion:");

        label_iTipo.setText("---------");

        label_iObservacion.setText("------");

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel13Layout.createSequentialGroup()
                        .addComponent(jLabel29)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(label_iNotificador, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel13Layout.createSequentialGroup()
                        .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(jPanel13Layout.createSequentialGroup()
                                    .addComponent(jLabel20)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(label_iReferencia, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel13Layout.createSequentialGroup()
                                    .addComponent(jLabel23)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(label_iZona, javax.swing.GroupLayout.DEFAULT_SIZE, 294, Short.MAX_VALUE))
                                .addGroup(jPanel13Layout.createSequentialGroup()
                                    .addComponent(jLabel27)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(label_iOperador, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGroup(jPanel13Layout.createSequentialGroup()
                                    .addComponent(jLabel28)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(label_iDescripcion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                            .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel13Layout.createSequentialGroup()
                                    .addComponent(jLabel30)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(label_iTipo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel13Layout.createSequentialGroup()
                                    .addComponent(jLabel31)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(label_iObservacion, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(0, 31, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addGap(37, 37, 37)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel20)
                    .addComponent(label_iReferencia))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel23)
                    .addComponent(label_iZona))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel29)
                    .addComponent(label_iNotificador))
                .addGap(10, 10, 10)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel27)
                    .addComponent(label_iOperador))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label_iDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel28))
                .addGap(40, 40, 40)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel30)
                    .addComponent(label_iTipo))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel31)
                    .addComponent(label_iObservacion))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addComponent(jPanel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("Incidente", jPanel10);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void Tabla_RegistroLlamadaMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Tabla_RegistroLlamadaMousePressed
        try {
            // TODO add your handling code here:
            int clave = (int) Tabla_RegistroLlamada.getValueAt(Tabla_RegistroLlamada.getSelectedRow(), 0);
            registroLlamada = ventana.getGestorRegistroLlamadas().buscar(clave);
            emergencie = ventana.getGestorEmergencia().buscar(clave);
            String cedulaOperador = registroLlamada.getOperador().getCedula();
            operador = ventana.getGestorOperadoras().buscar(cedulaOperador);
            label_Lugar.setText(registroLlamada.getCalle1());
            label_Zona.setText(emergencie.getZona());
            textArea_DescEmergencia.setText(emergencie.getDescripcionGeneral());
            EntidadEmergenciaDB ee = new EntidadEmergenciaDB();

            ArrayList listaEnt = ee.listarEntidades(emergencie.getId());
            /////////////////////////////////

            Object nameColumns[] = {"Entidad"};
            DefaultTableModel miTableModel = new DefaultTableModel(nameColumns, 0);
            for (int i = 0; i < listaEnt.size(); i++) {
                Object nuevaFila[] = {listaEnt.get(i)};
                miTableModel.addRow(nuevaFila);
            }
            tabla_Entidades.setModel(miTableModel);
            getTabla_OperadorAtendio();
            /////////////////////////////////////
        } catch (UsuarioException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        } catch (RegistroLlamadaException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        } catch (EmergenciaInicialException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        } catch (SQLException ex) {
            Logger.getLogger(Panel_SOS.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_Tabla_RegistroLlamadaMousePressed

    private void Tabla_NotificadorMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Tabla_NotificadorMousePressed
        try {
            // TODO add your handling code here:
            // int row =Tabla_Unidades.getSelectedRow();
            // System.out.println(Tabla_Notificador.getValueAt(Tabla_Notificador.getSelectedRow(), 0));
            String cedulaNotificador = (String) Tabla_Notificador.getValueAt(Tabla_Notificador.getSelectedRow(), 0);
            notificador = ventana.getGestorNotificadores().buscar(cedulaNotificador);
            getTabla_RegistroLlamada(ventana.getGestorRegistroLlamadas().tablaModelo(notificador));
        } catch (NotificadorException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        }

    }//GEN-LAST:event_Tabla_NotificadorMousePressed

    private void boton_GuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boton_GuardarActionPerformed
        // TODO add your handling code here:
        if (Operador.class.getName().equalsIgnoreCase(ventana.getPanel_Login().getClaseUsuario())) {
            try {

                notificador = ventana.getGestorNotificadores().buscar(text_Cedula.getText());
                guardarRegistroLlamada();
                guardarEmergencia();
                getTabla_NotificadorSOS();

            } catch (NotificadorException ex) {
                guardarNotificador();
            }


        } else {
            JOptionPane.showMessageDialog(null, "Solo los Operadores pueden realizar cambios");
        }
    }//GEN-LAST:event_boton_GuardarActionPerformed

    private void boton_BuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boton_BuscarActionPerformed
        try {
            // TODO add your handling code here:

            String cedulaBusqueda = text_BuscarCedula.getText();
            notificador = ventana.getGestorNotificadores().buscar(cedulaBusqueda);
            // if (notificador != null) {
            cargarNotificador();
            getTabla_NotificadorSOS();
            text_Cedula.setEnabled(false);
            //}

            text_BuscarCedula.setText("");
        } catch (NotificadorException ex) {
            text_Cedula.setEnabled(true);
            JOptionPane.showMessageDialog(null, ex.getMessage());
        }

    }//GEN-LAST:event_boton_BuscarActionPerformed

    private void tipo_EmergenciaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_tipo_EmergenciaItemStateChanged
        // TODO add your handling code here:


        if (evt.getStateChange() == 1) {
            boolean repetido = true;
            for (int i = 0; i < Tabla_Unidades.getRowCount(); i++) {
                if ((Tabla_Unidades.getValueAt(i, 0)).equals(evt.getItem())) {
                    repetido = false;
                    break;
                }
            }
            if (repetido) {
                DefaultTableModel miTableModel = (DefaultTableModel) Tabla_Unidades.getModel();
                Object nuevaFila[] = {evt.getItem()};
                miTableModel.addRow(nuevaFila);
                Tabla_Unidades.setModel(miTableModel);
            }
        }
    }//GEN-LAST:event_tipo_EmergenciaItemStateChanged
    public void resumenEmergencia() {
        try {
            String cedulaOperador = registroLlamada.getOperador().getCedula();
            String cedulaNotificador = registroLlamada.getNotificador().getCedula();
            operador = ventana.getGestorOperadoras().buscar(cedulaOperador);
            notificador = ventana.getGestorNotificadores().buscar(cedulaNotificador);
            label_iReferencia.setText(registroLlamada.getCalle1());
            label_iZona.setText(emergencie.getZona());
            label_iDescripcion.setText(emergencie.getDescripcionGeneral());
            label_iOperador.setText(operador.getNombre() + " " + operador.getApellido());
            label_iNotificador.setText(notificador.getNombre() + " " + notificador.getApellido());
        } catch (UsuarioException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        } catch (NotificadorException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        }
    }
    private void boton_BuscarEmergenciaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boton_BuscarEmergenciaActionPerformed
        // TODO add your handling code here:
        try {
            // TODO add your handling code here:
            int clave = Integer.parseInt(text_BuscarEmergecia.getText());
            registroLlamada = ventana.getGestorRegistroLlamadas().buscar(clave);
            emergencie = ventana.getGestorEmergencia().buscar(clave);

            resumenEmergencia();
        } catch (RegistroLlamadaException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        } catch (EmergenciaInicialException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        } catch (NumberFormatException ex) {
            JOptionPane.showMessageDialog(null, "ingrese numeros enteros por favor");
        }
    }//GEN-LAST:event_boton_BuscarEmergenciaActionPerformed
    private void guardarRegistroIncidente() {
        try {
            emergencie.setRegistroIncidentes(registroIncidente);
            ventana.getGestorResgistroIncidente().insertar(registroIncidente);
            //ventana.getGestorEmergenciaInicial().modificar(emergenciaInicial);
            getTabla_RegistroIncidente(ventana.getGestorResgistroIncidente().tablaModelo());
        } catch (RegistroIncidenteException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        } catch (AlfanumericoException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        } //        catch(PSQLException ex){
        //            JOptionPane.showMessageDialog(null, "Error: Clave duplicada");
        //        } 
        catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "Error SQL desconocido");
            Logger.getLogger(Panel_SOS.class.getName()).log(Level.SEVERE, null, ex);
        }
//        catch (EmergenciaInicialException ex) {
//            JOptionPane.showMessageDialog(null, ex.getMessage());
//        }
    }
    int ti = 0;
    private void boton_Guardar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boton_Guardar1ActionPerformed
        if (Coordinador.class.getName().equalsIgnoreCase(ventana.getPanel_Login().getClaseUsuario())) {
            try {
                // TODO add your handling code here:
                tipo = text_Tipo.getText();
                observacion = text_Observacion.getText();
                int clave = Integer.parseInt(text_BuscarEmergecia.getText());
                emergencie = ventana.getGestorEmergencia().buscar(clave);
                coordinador = ventana.getGestorCoordinadores().buscar(ventana.getPanel_Login().getCedula());

                TipoIncidente tipoIncidente = new TipoIncidente(ti++, tipo);

                registroIncidente = new RegistroIncidente(0, observacion, tipoIncidente, coordinador, emergencie);
                guardarRegistroIncidente();
            } catch (EmergenciaInicialException ex) {
                JOptionPane.showMessageDialog(null, ex.getMessage());
            } catch (UsuarioException ex) {
                JOptionPane.showMessageDialog(null, ex.getMessage());
            } catch (NumberFormatException ex) {
                JOptionPane.showMessageDialog(null, "ingrese numeros enteros por favor");
            }
        } else {
            JOptionPane.showMessageDialog(null, "Solo los Coordinadores pueden realizar cambios");
        }
    }//GEN-LAST:event_boton_Guardar1ActionPerformed

    private void tabla_RegistroIncidenteMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabla_RegistroIncidenteMousePressed
        try {
            // TODO add your handling code here:
            int clave = (int) tabla_RegistroIncidente.getValueAt(tabla_RegistroIncidente.getSelectedRow(), 0);
            registroIncidente = ventana.getGestorResgistroIncidente().buscar(clave);
            int claveEmergencia = registroIncidente.getClave();
            registroLlamada = ventana.getGestorRegistroLlamadas().buscar(claveEmergencia);
            emergencie = ventana.getGestorEmergencia().buscar(claveEmergencia);
            resumenEmergencia();
            tipo = registroIncidente.getTipoIncidente().getId() + "";
            label_iTipo.setText(tipo);
            observacion = registroIncidente.getObservacion();
            label_iObservacion.setText(observacion);
        } catch (RegistroIncidenteException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        } catch (RegistroLlamadaException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        } catch (EmergenciaInicialException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        }
    }//GEN-LAST:event_tabla_RegistroIncidenteMousePressed

    private void cmb_tipo_EmergenciaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cmb_tipo_EmergenciaItemStateChanged
        // TODO add your handling code here:
    }//GEN-LAST:event_cmb_tipo_EmergenciaItemStateChanged

    private void cmb_tipo_EmergenciaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmb_tipo_EmergenciaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cmb_tipo_EmergenciaActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTable Tabla_Notificador;
    private javax.swing.JTable Tabla_NotificardorSOS;
    private javax.swing.JTable Tabla_OperadorAtendio;
    private javax.swing.JTable Tabla_RegistroLlamada;
    private javax.swing.JTable Tabla_Unidades;
    private javax.swing.JButton boton_Buscar;
    private javax.swing.JButton boton_BuscarEmergencia;
    private javax.swing.JButton boton_Guardar;
    private javax.swing.JButton boton_Guardar1;
    private javax.swing.JComboBox cmb_tipo_Emergencia;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel label_Cedula;
    private javax.swing.JLabel label_Cedula1;
    private javax.swing.JLabel label_Lugar;
    private javax.swing.JLabel label_Zona;
    private javax.swing.JLabel label_iDescripcion;
    private javax.swing.JLabel label_iNotificador;
    private javax.swing.JLabel label_iObservacion;
    private javax.swing.JLabel label_iOperador;
    private javax.swing.JLabel label_iReferencia;
    private javax.swing.JLabel label_iTipo;
    private javax.swing.JLabel label_iZona;
    private javax.swing.JPanel panel_Llamadas;
    private javax.swing.JTable tabla_Entidades;
    private javax.swing.JTable tabla_RegistroIncidente;
    private javax.swing.JTextArea textArea_DescEmergencia;
    private javax.swing.JTextField text_Apellido;
    private javax.swing.JTextField text_BuscarCedula;
    private javax.swing.JTextField text_BuscarEmergecia;
    private javax.swing.JTextField text_Cedula;
    private javax.swing.JTextField text_Descripcion;
    private javax.swing.JTextField text_Direccion;
    private javax.swing.JTextField text_Lugar1;
    private javax.swing.JTextField text_Lugar2;
    private javax.swing.JTextField text_Nombre;
    private javax.swing.JTextField text_Observacion;
    private javax.swing.JTextField text_Telefono;
    private javax.swing.JTextField text_Tipo;
    private javax.swing.JTextField text_Zona;
    private javax.swing.JComboBox tipo_Emergencia;
    // End of variables declaration//GEN-END:variables
}
